package com.ht.module.bus.controller;

import com.ht.util.JsonResult;
import com.ht.util.Pager;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.ht.module.bus.entity.TStudentTripStatistics;
import com.ht.module.bus.service.TStudentTripStatisticsService;
import com.ht.util.*;

import javax.validation.Valid;
import java.util.List;


/**
 * <p>
 * 学生出行统计信息填报表 前端控制器
 * </p>
 *
 * @author hejialun
 * @since 2024-08-20
 */
@RestController
@RequestMapping("/t-student-trip-statistics")
public class TStudentTripStatisticsController {


    @Autowired
    private TStudentTripStatisticsService tStudentTripStatisticsService;



    @ApiOperation("分页查询")
    @GetMapping("/findPage")
    public JsonResult findPage(Pager<TStudentTripStatistics> pager, TStudentTripStatistics en) {
        return JsonResult.success(tStudentTripStatisticsService.findPage(pager, en));
    }


    @ApiOperation("通过id查询")
    @GetMapping("/get-by-id/{id}")
    public JsonResult getById(@PathVariable(value = "id") String id) {
        return JsonResult.success(tStudentTripStatisticsService.getById(id));
    }

    @ApiOperation("新增")
    @PostMapping("/add")
    public JsonResult add(@RequestBody @Valid TStudentTripStatistics en) {
        CommMethod.beanCreate(en);
        tStudentTripStatisticsService.add(en);
        return JsonResult.success();
    }

    @ApiOperation("批量新增")
    @PostMapping("/addList")
    public JsonResult addList(@RequestBody @Valid List<TStudentTripStatistics> list) {
        Integer i = tStudentTripStatisticsService.addList(list);
        return JsonResult.success(i);
    }


    @ApiOperation("通过id删除")
    @DeleteMapping("/delete-by-id/{id}")
    public JsonResult delete(@PathVariable(value = "id") String id) {
        tStudentTripStatisticsService.removeById(id);
        return JsonResult.success();
    }

    @ApiOperation("修改")
    @PutMapping("/update")
    public JsonResult updateById(@RequestBody @Valid TStudentTripStatistics en) {
        CommMethod.beanUpdate(en);
        tStudentTripStatisticsService.editById(en);
        return JsonResult.success();
    }

}
